<!DOCTYPE HTML>
<html>
<head>
<meta charset="UTF-8">
<title>Login PHP</title>
<link rel="stylesheet" href="loginResources/style.css" />
<!-- <link href='http://fonts.googleapis.com/css?family=Oleo+Script' -->
<!-- 	rel='stylesheet' type='text/css'> -->
<script src="formValidator/jquery-1.4.4.js" type="text/javascript"></script>
<script type="text/javascript">
function login() {
		var username = document.getElementById("username").value;
		var password = document.getElementById("password").value;
		if (username.length == 0 || password.length == 0) {
			alert("用户名和密码不能为空");
		} else {
			var userInfo = new Object();
			userInfo.username = username;
			userInfo.password = password;
			$.ajax({
				type : "GET",
				url : "../user/login" + "/" + username + "/" + password,
				dataType : "json",
				contentType : "application/json",
				success : function(data) {

					if (data.states != "OK") {
						alert("用户名密码不正确");
					} else {
						if(data.user.level=="1"){
						window.location.href = "../bootstrap/home.html";
						}else if(data.user.level=="0"){
							window.location.href = "../bootstrap/vis.html";
						}else{
							window.location.href = "../bootstrap/parent.html";
						}
					}
				}
			});
		}
	}
</script>
</head>
<body>
	<div class="lg-container">
		<h1>Admin Area</h1>
		<div  id="lg-form" name="lg-form">

			<div>
				<label for="username">Username:</label> <input type="text"
					name="username" id="username" placeholder="username" />
			</div>

			<div>
				<label for="password">Password:</label> <input type="password"
					name="password" id="password" placeholder="password" />
			</div>

			<div>
				<button type="submit" id="login" onclick="login()">Login</button>
			</div>

		</div>
		<div id="message"></div>
	</div>
</body>
</html>